<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base target="_self">
<%@include file="/common/meta.jsp"%>
<style type="text/css">
#itemLeft {
	width: 150px;
	height: 325px;
	overflow: auto;
}

#itemLeft ul {
	line-height: 25px;
	margin: 5px 0px 0px 25px;
}

#itemContent {
	margin: 5px;
	width: 460px;
	height: 325px;
	overflow: auto;
}

.item {
	height:25px;
	line-height: 25px;
	width: 150px;
	float: left;
}

.noborder {
	border: 0px;
}

#tableContent {
	border: 2px solid #97B7E7;
}

.title {
	padding: 5px;
	font-weight: bold;
}
</style>
<title>科目选择</title>
</head>
<body>
<table id="tableContent" align="center" width="630" cellpadding="0" cellspacing="0" >
  <tr>
    <td colspan="2">
      <div class="x-toolbar title" style="border-bottom: 0px;">
        <s:if test="dept != null">
          <span><b>部门【<font color="green">${dept.name}</font>】</b>涉及的财务科目：</span>
	    </s:if>
	    <s:elseif test="project != null">
	      <span><b>项目【<font color="green">${project.name}</font>】</b>涉及的财务科目：</span>
	    </s:elseif>
	    <s:else>
	        <form action="selectItem.do" method="post" style="margin: auto;">
	          <span><b>科目查询：</b></span>
	          <s:textfield name="model.name" maxlength="255" size="25"/>&nbsp;${isRadio}
	          <input type="submit" value="查询" class="button">
	          <span style="width:220px;"></span>
	          <input type="button" class="button" value="关闭并保存" onclick="returnSelectValue()">
	        </form>
	    </s:else>
      </div>
    </td>
  </tr>
  <tr>
    <td width="150" valign="top" style="border-right: 1px solid #97B7E7;">
      <div class="x-toolbar title" >财务科目分类</div>
      <div id="itemLeft">
         <ul>
           <s:iterator value="parents" var="pitem">
             <li><a href="selectItem.do?parentId=${pitem.id}">${pitem.name}</a></li>  
           </s:iterator>
         </ul>
      </div>
    </td>
    <td width="480">
      <div class="x-toolbar title">科目明细</div>
      <div id="itemContent">
        <s:iterator value="items" var="item">
          <div class="item">
            <s:if test='inputType == "radio"'>
              <input type="radio" name="item" class="noborder" value="${item.id}" title="${item.name}" id="${item.code}"  onclick="checkItem(this)">${item.name}
            </s:if>
            <s:else>
              <input type="checkbox" class="noborder" value="${item.id}" onclick="checkItem(this)"> ${item.name}
            </s:else>
          </div>
        </s:iterator>
      </div>
    </td>
  </tr>
</table>
${isRadio }
<s:hidden id="selectedItems" />
<script type="text/javascript">
var spliteStr = ",";
function checkItem(obj){
	var type = '${inputType}';
	if (type == 'radio'){
		var item = new Object();
		item.code = obj.id;
		item.name = obj.title;
		item.id = obj.value;
		window.returnValue = item;
		window.close();
	}else{
		var selectedItems = $("#selectedItems").val();
		if (obj.checked){
			selectedItems = selectedItems + obj.value + spliteStr;
		}else{
			selectedItems = selectedItems.replace((obj.value + spliteStr), '');
		}
		$("#selectedItems").val(selectedItems);
	}
}

//关闭窗口，返回数据
function returnSelectValue(){
	window.returnValue = $("#selectedItems").val();
	window.close();
}
</script>
</body>
</html>